package org.jeecg.modules.vital.service.impl;

import org.jeecg.modules.vital.entity.TreatmentRecord;
import org.jeecg.modules.vital.entity.OperationRecords;
import org.jeecg.modules.vital.entity.DruguseRecodes;
import org.jeecg.modules.vital.mapper.OperationRecordsMapper;
import org.jeecg.modules.vital.mapper.DruguseRecodesMapper;
import org.jeecg.modules.vital.mapper.TreatmentRecordMapper;
import org.jeecg.modules.vital.service.ITreatmentRecordService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 治疗记录
 * @Author: jeecg-boot
 * @Date:   2023-01-04
 * @Version: V1.0
 */
@Service
public class TreatmentRecordServiceImpl extends ServiceImpl<TreatmentRecordMapper, TreatmentRecord> implements ITreatmentRecordService {

	@Autowired
	private TreatmentRecordMapper treatmentRecordMapper;
	@Autowired
	private OperationRecordsMapper operationRecordsMapper;
	@Autowired
	private DruguseRecodesMapper druguseRecodesMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		operationRecordsMapper.deleteByMainId(id);
		druguseRecodesMapper.deleteByMainId(id);
		treatmentRecordMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			operationRecordsMapper.deleteByMainId(id.toString());
			druguseRecodesMapper.deleteByMainId(id.toString());
			treatmentRecordMapper.deleteById(id);
		}
	}
	
}
